<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="root">
        <div>
            <input type="text" v-model="title" @keyup.enter='onEnter' name="" id="">

        </div>
        <ul>
            <li v-for="(item,index) in todos" :key="item">
                <span>{{item}}</span>
                <span @click="del(index)"> -- 删除</span>
            </li>
        </ul>
    </div>


    <script>
        const vm = new Vue({
            el: '#root',
            data: {
                title: '',
                todos: []
            },
            methods: {
                onEnter(evt) {
                    this.todos.push(this.title)
                    this.title = ''
                },
                del(index){
                    this.todos.splice(index,1)
                }
            }
        })
    </script>

</body>

</html>